<?php
declare(strict_types=1);
namespace SixShop\Eav\Controller;


use SixShop\Core\Request;
use SixShop\Eav\Entity\EavAttributeOptionEntity;
use think\Response;


use function SixShop\Core\success_response;

class AttributeOptionController
{
    public function index(Request $request, EavAttributeOptionEntity $entity): Response
    {
        $attributeId = $request->get('attribute_id/d');
        return success_response($entity->where(['attribute_id' =>$attributeId])->select());
    }

    public function save(Request $request, EavAttributeOptionEntity $entity): Response
    {
        $data = $request->post();
        return success_response($entity->save($data));
    }
    public function update(int $id, Request $request, EavAttributeOptionEntity $entity): Response
    {
        return success_response($entity->update($request->post(), ['id' => $id]));
    }
    public function delete(int $id, EavAttributeOptionEntity $entity): Response
    {
        return success_response($entity->destroy($id));
    }
}